<%@include file="header.jsp" %>
<%@page import="futbolfacil.modelo.Cancha"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Collection"%>   
<script type="text/javascript">
	function ValidaCampos(){
		var dis = document.frmBuscarCancha.txtDistrito.value;
		var hin = document.frmBuscarCancha.txtHorIni.value;
		var hfi = document.frmBuscarCancha.txtHorFin.value;
		if (dis == "") {
			alert("Ingrese el distrito");
			return false;
		} else if (hin == "") {
			alert("Ingrese la hora de inicio");
			return false;
		} else if (hfi == "") {
			alert("ingrese la hora de fin");
			return false;
		} 
		return true;
	}
</script>
    <!-- content -->
    <div id="content">
      <div id="indent">
        <div class="wrapper">
          <div class="col-1">

            <div class="box">
              
                              <div class="inner">
                                <div class="wrapper">
                                  <ul class="list">
                                   <li><a href="ListarCanchasServlet">Buscar cancha</a></li>
                                   
                                  </ul>
                                </div>
                              </div>
                          
            </div>
          </div>
          <div class="col-2">
            <div class="box-2">
             
                              <div class="inner">
                                <div class="wrapper">

                                    <h1>Buscar Cancha</h1>
                                    <div id="insert" style="width:600px;">
                                    <fieldset>
                                    <legend>Busqueda</legend>
                                    
                                    <% 
                                    String valor = String.valueOf(request.getAttribute("valor")); 
                                    if (valor.equals("")) valor = "false";
                                    if (valor.equals("true")) { 
                                    %>
                                    <div id="errores" style="width:95%; padding:10px; border:solid 1px red; margin-top:10px; margin-bottom:10px; color:red; background:#f8f8ff;">
                                    	${msg1}                                    	
                                    </div>
                                    <% } %>
                                    
									<form onSubmit="return ValidaCampos();" name="frmBuscarCancha" method="POST" action="ListarCanchasServlet">
										
										<label>Distrito:</label>
										<select name = "cboDistrito">
		                                   	<option>Cercado de Lima</option>
											<option>Ate</option>
											<option>Barranco</option>
											<option>Brena</option>
											<option>Comas</option>
											<option>Chorrillos</option>
											<option>Jesus Maria</option>
											<option>La Molina</option>
											<option>La Victoria</option>
											<option>Lince</option>
											<option>Miraflores</option>
											<option>Rimac</option>
											<option>San Isidro</option>
											<option>San Luis</option>
											<option>San Miguel</option>
											<option>Santiago de Surco</option>
											<option>Surquillo</option>
											<option>Los Olivos</option>
											<option>San Borja</option>
											<option>Villa El Savador</option>
											<option>Santa Anita</option>
											<option>Pueblo Libre</option>
											<option>Puente Piedra</option>
											<option>San Juan de Miraflores</option>
											<option>San Juan de Lurigancho</option>
											<option>San Martin de Porres</option>
											<option>Independencia</option>
										</select><br>
										<label>Dia:</label>
										<select name="cboDia">
										<option value="Lunes">Lunes</option>
										<option value="Martes">Martes</option>
										<option value="Miercoles">Miercoles</option>
										<option value="Jueves">Jueves</option>
										<option value="Viernes">Viernes</option>
										<option value="Sabado">Sabado</option>
										<option value="Domingo">Domingo</option>	
										</select><br />	
	                                    <label>Hora Inicio:</label>
	                                    <select name="cboHoraInicio">	
		                                    <%		
 		                                    ArrayList<String> horasI = (ArrayList<String>) request.getAttribute("ListadoHoras");
		                                    if(horasI != null) {
			                                    for(String hora : horasI){ 
				                                    out.println("<option value='"+ hora +"' > "+ hora +"</option>");
			                                    }
		                                    }
		                                    %>
	                                    </select><br />	
	                                    <label>Hora Fin:</label>
	                                    <select name="cboHoraFin">	
		                                    <%		
 		                                    ArrayList<String> horasF = (ArrayList<String>) request.getAttribute("ListadoHoras");
		                                    if(horasF != null) {
			                                    for(String hora : horasF){ 
				                                    out.println("<option value='"+ hora +"' > "+ hora +"</option>");
			                                    }
		                                    }
		                                    %>
	                                    </select><br />											
										<label>&nbsp;</label><input type="submit" name = "btnBuscar" value="Buscar"><br>
									</form>

                                    </fieldset>
                                    </div>
                                    <div id="grdCancha">
									    <table class='tabla02' width='100%'>
											<tr>
												<th><strong>Local</strong></th>
												<th><strong>Descripcion</strong></th>
												<!--<th><strong>Nombre</strong></th>-->
												<th><strong>Caracteristicas</strong></th>
												<th><strong>Precio</strong></th>
												<th><strong>Acciones</strong></th>
											</tr>
											<%
											Collection<Cancha> oCanchas = (ArrayList<Cancha>)request.getAttribute("ListadoCanchas");
											if(oCanchas != null) { 
											for(Cancha x : oCanchas) {
											%>  
											  <tr>
											    <td><% out.print(x.getLocalCancha().getDescripcionLocal()); %></td>
											    <!--<td><% //out.print(x.getCodigoCancha()); %></td>-->
											    <td><% out.print(x.getDescripcionCancha()); %></td>
											    <td><% out.print(x.getCaracteristicasCancha()); %></td>
											    <td><% out.print(x.getPrecioCancha()); %></td>
											    <td><a href="HorarioCanchaServlet?idCancha=<%=x.getCodigoCancha()%>">Alquilar</a></td>
											  </tr>
											<% }  
											  } %>
											  
										</table>
									</div>
                                </div>
              </div>
                            
            </div>
          </div>

        </div>
      </div>
    </div>
<%@include file="footer.jsp" %>